	CHARACTER*20 TIT(60),TITL
	CHARACTER*4 CBTT(60),YEAR,CBT
	CHARACTER*12 MARK
	CHARACTER*10 ADD
	INCLUDE 'SYS$LIBRARY:FORIOSDEF/LIST'
	DIMENSION DAT(12),REAL(12)
C
C
	OPEN(UNIT=1,FILE='HYDROMET:[MPOLL]MONTHLY.IND',STATUS='OLD',
	1ORGANIZATION='INDEXED',ACCESS='KEYED',
	2RECORDTYPE='FIXED',SHARED,FORM='UNFORMATTED',RECL=18,
	3KEY=(1:10:CHARACTER),IOSTAT=IOS,ERR=9999)
C
C
C
C
17	FORMAT(' ERROR ON OPEN UNIT=1, IOS=',I2)
18	FORMAT(' ERROR ON READ UNIT=1, IOS=',I2,5X,A)
19	FORMAT(' ERROR ON REWRITE IOS=',I2,/1X,A,12F8.1)
21	FORMAT(' ERROR ON WRITE IOS=',I2,/1X,A,12F8.1)
53	FORMAT(1X,A,12F9.1)
54	FORMAT(' MONTHLY FILE NOT UPDATED',/1X,A,12F9.1)
C
C
	MARK='            '
	IC=1
10	READ(2,1,END=109)TIT(IC),CBTT(IC)
	IC=IC+1
1	FORMAT(A,1X,A)
	GO TO 10
109	IC=IC-1
100	READ(3,2,END=201)TITL,NO
2	FORMAT(1X,A,I2)
	DO 12 I=1,IC
	IF(TITL.EQ.TIT(I))CBT=CBTT(I)
12	CONTINUE
	KN=(12-NO)*6+3
	READ(3,3,END=201)(DAT(I),I=1,NO),YEAR
3	FORMAT(1X,<NO>F6.0,<KN>X,A)
	IF(NO.EQ.12)GO TO 51
	DO 31 I=1,NO
	IF(DAT(I).LT.0.0)DAT(I)=0.0
	MARK(I:I)='H'
31	CONTINUE
	DO 11 I=NO+1,12
	DAT(I)=998877.
11	CONTINUE
51	ADD=CBT//'17'//YEAR
	WRITE(6,53)ADD,(DAT(I),I=1,12)
400	READ(UNIT=1,KEY=ADD,KEYID=0,IOSTAT=IOS,ERR=9998)ADD,REAL,MARK
	DO 32 I=1,NO
	MARK(I:I)='H'
32	CONTINUE
 	IF(IOS.EQ.0)REWRITE(UNIT=1,IOSTAT=IOS,ERR=501)ADD,DAT,MARK
	UNLOCK 1
	GO TO 100
9998	WRITE(6,18)IOS,ADD
	IF(IOS.EQ.52)CALL RECLOCK(*500,*400)
 	IF(IOS.EQ.36)WRITE(UNIT=1,IOSTAT=IOS,ERR=502)ADD,DAT,MARK
	GO TO 100
500	WRITE(6,54)ADD,(DAT(I),I=1,12)
	GO TO 100
501	WRITE(6,19)IOS,ADD,(DAT(I),I=1,12)
	GO TO 100
502	WRITE(6,21)IOS,ADD,(DAT(I),I=1,12)
	GO TO 100
9999	WRITE(6,17)IOS
201	STOP
	END
	SUBROUTINE RECLOCK(*,*)
C
C	TRIES TO READ LOCKED RECORD 5 TIMES AT 1 SECOND INTERVALS
C
	COMMON NAP,IOS
C
	LOGICAL*1 BTIME(8)
C
	CHARACTER ATIM*13
C
	DATA ATIM/'0 00:00:01.00'/
C
 	WRITE(6,2) NAP,IOS
2	FORMAT(1X,'RECORD LOCKED, NAP = ',I2,', IOS = ',I2)
C
	ISTAT=SYS$BINTIM(ATIM,BTIM)	! GET BINARY PAUSE
	RETVAR=SYS$SCHDWK(,,BTIM,)
	RETVAR=SYS$HIBER()	! FALL ASLEEP FOR 1 SECOND
	NAP=NAP+1
	IF(NAP.LT.10) RETURN 2
	WRITE(6,1) IOS
1	FORMAT(1X,'ERROR ON READ IN RECLOCK, IOS = ',I2)
	NAP=0
	RETURN 1
	END
